package com.neperia.migratore;

//import java.util.ArrayList;

public class Riga {
	public String nome_db;
	public String nome_tabella;
	public int len_tabella;
	public String nome_chiave;
	public int offset_chiave;
	public int len_chiave;
	public int len_campo;
	public String type_chiave;
	public String chiave_univoca;
	//public String nome_parent;
	//private int numSons = 15;

	public String parent;

	public boolean isRoot = false;

	public Riga(String data){
		//System.out.println(data);
		
		if(data.indexOf(";")!=-1){
			String tmp[] = data.split(";");
			this.nome_db=tmp[0].trim();
			this.nome_tabella=tmp[1].trim();
			this.len_tabella=Integer.parseInt(tmp[2]);
			this.nome_chiave=tmp[3].trim();
			this.len_chiave=Integer.parseInt(tmp[4]);
			this.len_campo=Integer.parseInt(tmp[5]);
			this.offset_chiave=Integer.parseInt(tmp[6]);
			this.type_chiave=tmp[7].trim();
			this.chiave_univoca=tmp[8].trim();
			if(!tmp[9].trim().equals("")){
				this.parent=tmp[9].trim();
				this.isRoot=false;
			}else{
				this.parent="";
				this.isRoot=true;
			}
			//int j=0;
			//System.out.println(tmp.length);
			/*if(!tmp[9].trim().equals("")){
				parent = new String[tmp.length-9];
				if(tmp.length>9){
					for(int i=9;i<tmp.length;i++){
						this.parent[j]=tmp[i];
						j++;
					}
				}
			}*/
			/*if(this.blocco[0].len_parent==0){
				this.isRoot=true;
			}*/
		}

	}
	/*
	public Riga[] getSons(Riga[] r, String nome_padre){

		ArrayList<Riga> sons = new ArrayList<Riga>();

		for(int i=0;i<r.length;i++){
			if(r[i].blocco[0].nome_parent.equals(nome_padre)){
				sons.add(r[i]);
			}
		}
		System.out.print("Padre: "+nome_padre+" - ");
		Riga[] s = null;
		if(sons.size()>0){
			s = new Riga[sons.size()];
			for(int i=0;i<sons.size();i++){
				s[i]=sons.get(i);
				System.out.print(s[i].nome_tabella+", ");
			}
		}
		System.out.println("!");
		return s;

	}*/
}

